package main

import (
    "fmt"
)

type Fruit interface {
	grow()
	harvest()
	plant()
}

type Apple struct {
	Fruit
}

func (a *Apple) grow() {
	fmt.Println("苹果长大")
}
func (a *Apple) harvest() {
	fmt.Println("苹果丰收")
}
func (a *Apple) plant() {
	fmt.Println("拼过浇水")
}

type FruitGardener struct {
}

func (fg *FruitGardener) factory(type1 string) Fruit {
	var fruit Fruit
	if type1 == "apple" {
		fruit = new(Apple)
	}
	return fruit
}

func main() {
	fg := new(FruitGardener)
	fruit := fg.factory("apple")
	fruit.grow()
	fruit.plant()
	fruit.harvest()
}
